export function param(obj:object, traditional:boolean=false) {
  const pairs: string[] = []

  for(const name in obj) {
    const value = Reflect.get(obj, name)
    if(Array.isArray(value)) {
      const item = value.reduce((prev, val)=>{
        return prev+=`${encodeURIComponent(name)}`+( traditional ? '' : '[]')+`=${encodeURIComponent(val)}&`
      }, '')
      pairs.push(item.slice(0, item.length-1))
    } else {
      pairs.push(`${encodeURIComponent(name)}=${encodeURIComponent(value)}`)
    }
  }

  return pairs.join('&').replace(/%20/g, '+')
}

